import axios from "../../utils/axios"
Component({
  options: {
    addGlobalClass: true,
  },
  data: {
    starCount: 0,
    forksCount: 0,
    visitTotal: 0,
    role:null
  },
  pageLifetimes:{
    show(){
      console.log(123)
    }
  },
  attached() {
    let that = this;
    wx.showLoading({
      title: '数据加载中',
      mask: true,
    })
    axios.get("/app/getAmount",{
      companyId:wx.getStorageSync('company_id')
    }).then(res=>{
      that.setData({
        starCount: res.total,
        forksCount: res.amount,
        visitTotal: res.balance
      })
    })
    wx.hideLoading()
  },
  methods: {
    onShow(){
      this.setData({
        role:wx.getStorageSync('role')
      })
    },
    coutNum(e) {
      if (e > 1000 && e < 10000) {
        e = (e / 1000).toFixed(1) + 'k'
      }
      if (e > 10000) {
        e = (e / 10000).toFixed(1) + 'W'
      }
      return e
    },
    showModal(e) {
      this.setData({
        modalName: e.currentTarget.dataset.target
      })
    },
    hideModal(e) {
      this.setData({
        modalName: null
      })
    },
    tixian(){
      wx.navigateTo({
        url: '/pages/user/tixian/index',
      })
    },
    cashBill(){
      console.log("cashBill")
      wx.navigateTo({
        url: '/pages/user/cashBill/index',
      })
    },
    logout(){
      wx.clearStorage();
      setTimeout(()=>{
        axios.get("/app/orderList",{
          current:1,
          pageSize:999,
          type:1
        })
      },1000)
    }
  }
})